<template>
	<view v-if="adSellerNo.includes(sellerNo)">
		<shadePopup :show="showAdPopup" @close="onAdPopupClose" v-if="adPopupList.length">
			<view class="coupons2">
				<swiper :indicator-dots="true" :autoplay="false" :interval="2000" :duration="500" indicator-col="#FEA48F"
					class="coupons2-swiper" indicator-active-color="#FFFFFF">
					<swiper-item class="coupons2-swiper-item" @click="adClick(item)" v-for="(item, index) in adPopupList"
						:key="index">
						<image :src="item.imgUrl" class="swiperitem"></image>
					</swiper-item>
				</swiper>
			</view>
		</shadePopup>

		<swiper class="swiper-banner" :indicator-dots="true" :autoplay="false" :circular="true" :vertical="false"
			:interval="3000" :duration="500" indicator-color="rgba(255, 255, 255, 0.4)" indicator-active-color="#fff"
			v-if="adBannerList.length">
			<swiper-item v-for="(item, index) in adBannerList" :key="index" @click="adClick(item)">
				<image :src="item.imgUrl" mode="aspectFill" class="swiper-item-images" />
			</swiper-item>
		</swiper>
	</view>
</template>

<script>
var app = getApp();
import shadePopup from '../shadePopup/shadePopup';
import https_1 from "@/api/https"

export default {
	components: {
		shadePopup,
	},

	data() {
		return {
			showAdPopup: true,
			// 弹窗广告列表
			adPopupList: [],
			// 轮播图广告列表
			adBannerList: [],
			adSellerNo: ['zyx'] // 开启广告的商户
		};
	},

	/**
	 * 组件的属性列表
	 */
	props: {
		adIdList: { // 属性名
			type: Array,
			value: () => []
		},
	},

	created() {
		if (this.adSellerNo.includes(this.sellerNo)) {
			this.getAdList()
		}
	},

	/**
	 * 组件的方法列表
	 */
	methods: {
		onAdPopupClose() {
			this.showAdPopup = false
		},
		adClick(item) {
			uni.navigateTo({
				url: `/pages/webViewPage/webViewPage?src=${encodeURIComponent(item.jumpUrl)}`
			});
		},
		getAdList() {
			https_1.getMemberAddr().then(res => {
				console.log(res, '会员地址')
				let IP = res.data
					if (IP) {
						let { adIdList } = this
						adIdList.forEach(AdvertisementType => {
							https_1.getAdvertise({
								AdvertisementType, //广告位ID
								IP, //客户端IP ,用户的真实ip
								Pid: '89F47359C5AD469CA84836B32EFBAE33', //车场ID
								partnerId: '8830434570', // 流量主ID
								gridId: '350100202407023262', // 场地ID
								adPosId: '3', // 3:输入车牌；4:支付页
								medium: '2', // 1-公众号;2-小程序;3-APP:4-支付宝生活号
							}).then(res => {
								if (res.code == 0 && res.data && res.data.code == 200) {
									const adData = res.data.data
									if (adData.advertType == 3) {
										this.adPopupList.push(adData)
									} else if (adData.advertType == 1) {
										this.adBannerList.push(adData)
									}
								}
							})
						})
					}
			})
		},
	}
};
</script>
<style lang="less" scoped>
@import "@/commin/commin.less";

.coupons2 {
	width: 580rpx;
	height: 620rpx;
	border-radius: 16rpx;
	overflow: hidden;

	.coupons2-swiper {
		width: 100%;
		height: 100%;

		.coupons2-swiper-item {
			.swiperitem {
				width: 100%;
				height: 100%;
			}
		}
	}

	.coupons2-delete {
		position: absolute;
		top: 0rpx;
		right: 0;
	}
}



.swiper-banner {
	height: 302rpx;
	margin: 0px 24rpx;

	.message {
		display: flex;
		align-items: center;
		// height: 67rpx;
		padding: 40rpx 30rpx 40rpx 33rpx;
		margin: 32rpx 24rpx;
		background: linear-gradient(0deg, #FFFFFF, #F4F6F8);
		border: 2rpx solid #FFFFFF;
		box-shadow: 4rpx 7rpx 20rpx 0rpx rgba(166, 171, 179, 0.24);
		border-radius: 16rpx;
		font-size: 30rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: @text-color1;

		.img {
			width: 51rpx;
			height: 38rpx;
			margin-right: 27rpx;
		}

		.message-swiper {
			width: 638rpx;
			height: 48rpx;
			line-height: 48rpx;
			font-size: 30rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: @text-color1;

			.text {
				-webkit-box-orient: vertical; // 避免压缩后删除此行
				-webkit-line-clamp: 1; // 显示省略号行数
				display: -webkit-box;
				overflow: hidden;
				/*隐藏*/
				white-space: nowrap;
				/*不换行*/
				text-overflow: ellipsis;
				/* 超出部分省略号 */
			}
		}
	}

	.swiper-item-images {
		.kuangao(702rpx, 302rpx);
		.borderradius(16rpx, 16rpx, 16rpx, 16rpx);
	}
}
</style>